<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>前台</title>
</head>

<body>
    <button onclick="onCreated()">生成项目</button>
    <div id="app">
        <span v-text="userInfo.aaa"></span>
        {{userInfo.aaa}}
        <div>
            {{userInfo.bbb}}
            <input type="text" v-model="userInfo.aaa">
        </div>
    </div>
    <script src="./config.js"></script>
    <script>
        // var abc = {
        //     userInfo: {
        //         aaa: "1111",
        //         bbb: "啊啊啊啊啊"
        //     }
        // };
        // var ret = new dataInsert("app", abc);
        // setTimeout(function () {
        //     ret.setData({
        //         userInfo: {
        //             aaa: "2222",
        //             ccc: "555"
        //         }
        //     });
        // }, 1000)
        
        console.log(/^'|"(.*?)'|"$/.test("'1111'"));

        function onCreated() {
            request("/project/create", config, function (res) {
                console.log(res);
            });
        }

        function request(url, data, callback) {
            var requestObj = new XMLHttpRequest();
            requestObj.open("POST", url, true);
            requestObj.setRequestHeader("Content-Type", "application/json");
            requestObj.send(JSON.stringify(data));
            requestObj.onreadystatechange = () => {
                if (requestObj.readyState == 4) {
                    if (requestObj.status === 200) {
                        var result = requestObj.response;
                        if (typeof result !== 'object') {
                            result = JSON.parse(result);
                        }
                        callback(result);
                    } else {
                        console.error(requestObj.response);
                    }
                }
            }
        }
    </script>
</body>

</html>